import type { Server } from './model';

import type { ID, PageQuery } from '#/api/common';

import { requestClient } from '#/api/request';

enum Api {
  addSubscribe = '/iot/server/subscribe/save',
  delSubscribe = '/iot/server/subscribe/remove',
  subscribeDetail = '/iot/server/subscribe/detail',
  subscribeList = '/iot/server/subscribe/page',
  updateSubscribe = '/iot/server/subscribe/update',
}

/**
 * 新增
 * @param data 参数
 */
export function addSubscribe(data: Partial<Server>) {
  return requestClient.postWithMsg<void>(Api.addSubscribe, data);
}

/**
 * 列表
 * @returns list
 */
export function subscribeList(params?: PageQuery) {
  return requestClient.get(Api.subscribeList, { params });
}

/**
 * 删除
 * @param id
 */
export function delSubscribe(id: ID) {
  return requestClient.postWithMsg<void>(`${Api.delSubscribe}?id=${id}`);
}

/**
 * 修改
 * @param id
 */
export function updateSubscribe(data: Partial<Server>) {
  return requestClient.postWithMsg<void>(Api.updateSubscribe, data);
}

/**
 * 详情
 * @returns list
 */
export function subscribeDetail(id: ID) {
  return requestClient.get<Server>(`${Api.subscribeDetail}?id=${id}`);
}
